package com.xunji.standard.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xunji.standard.entity.NdAnalysisData;
import com.xunji.standard.mapper.NdAnalysisDataMapper;
import com.xunji.standard.service.NdAnalysisDataService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 * @description 针对表【t_st_nd_analysis_data】的数据库操作Service实现
 * @createDate 2025-07-03 09:30:51
 */
@Service
public class NdAnalysisDataServiceImpl extends ServiceImpl<NdAnalysisDataMapper, NdAnalysisData> implements NdAnalysisDataService {

    @Override
    public boolean hasTask(String caseId, Long infoId) {
        QueryWrapper<NdAnalysisData> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId).eq("info_id", infoId).orderByDesc("id");
        List<NdAnalysisData> data = this.baseMapper.selectList(qw);
        if (data == null || data.isEmpty()) return false;
        NdAnalysisData analysisData = data.get(0);
        if (analysisData.getJxzt() == 1) {
            return false;
        }
        if (analysisData.getJxzt() == 2) {
            return false;
        }
        if (analysisData.getJxzt() == 0) {
            return true;
        }
        return false;
    }

    @Override
    public List<NdAnalysisData> getListByInfoIdAndCaseId(String caseId, Long infoId) {
        QueryWrapper<NdAnalysisData> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId)
                .eq("info_id", infoId).orderByDesc("id");
        return this.baseMapper.selectList(qw);
    }
}
